﻿using System.Collections.Generic;
using Microsoft.CodeAnalysis;

namespace UIOC.CodeAnalysis.Extensions;

internal static class NamespaceSymbolExtensions {

    public static string GetFullNamespaceName(this INamespaceSymbol namespaceSymbol) {
        if (namespaceSymbol.IsGlobalNamespace)
            return string.Empty;

        var parts = new List<string>();
        var current = namespaceSymbol;
        while (!current.IsGlobalNamespace) {
            parts.Add(current.Name);
            current = current.ContainingNamespace;
        }
        parts.Reverse();
        return string.Join(".", parts);
    }
}
